Dynamic documents with code

ANU BDSI
workshop
Reproducible research with Quarto

Emi Tanaka

Biological Data Science Institute

12th April 2024

Current learning objective

  • -Generate HTML, PDF, or Word documents using Markdown syntax
  • -Understand the anatomy of Quarto documents
  • Develop dynamic documents containing code (in R, Python, or Julia) using Quarto
  • Implement various code chunk options to customize chunk behaviour
  • -Recognize the significance of reproducibility and grasp the concept of literate programming
  • -Apply reproducible practices
  • -Establish an organized folder structure for data projects

Code chunk

Chunk options

```{r}
#| label: fig-plot
#| eval: true
#| echo: true
#| fig-width: 4
#| fig-height: 4
#| fig-cap: "A scatter plot of speed and distance."
library(ggplot2)
ggplot(cars, aes(speed, dist)) + geom_point()
```

Quarto (and R Markdown) is not just for R

  • To use Python, change the language to python:
```{python}
2 * 2 + 3
```
7
  • To use Julia, change the language to julia:
```{julia}
3 + 3
```
6

Inline code

Inline R commands

  • Note that these inline R command only work if engine: knitr.
  • This doesn’t work for other languages.

Stack components as you like!